#ifndef __FL_NETWORK_MANAGER_H__
#define __FL_NETWORK_MANAGER_H__

#include "cocos2d.h"
#include "TcpSocket.h"

#define LOGIN_SOCKET_TAG		1

class NetworkManager 
{
public:
	NetworkManager();
	~NetworkManager();

	static NetworkManager* getSingleton();

	void update(float dt);

	TCPSocket *createSocket(const char* pszServerIP, int nServerPort,	int _tag,	NetworkProtocol* protocol,
		int nBlockSec = BLOCKSECONDS,	bool bKeepAlive = false);
	bool addSocket(TCPSocket *pSocket);
	bool removeSocket(int _tag);
	TCPSocket* findSocket(int _tag);

	void callRemoteCommand(TCPSocket* socket, int cmd_id, ...);
	void callRemoteCommand(int socket_tag, int cmd_id, ...);

private:
	static NetworkManager* m_Singleton;

	typedef std::list<TCPSocket*> SocketList;
	SocketList m_lstSockets;
};

#endif